var Adv_skd=require("./Adv_skd")

var e = require;
var t = module;
var o = exports;
var n,
    i = e("TreasureChestBox").TreasureBox,
    a = e("Interstitial").InterstitialType,
    r = o,
    s =
        ((n = function (e, t) {
            return (n =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
                })(e, t);
        }),
        function (e, t) {
            function o() {
                this.constructor = e;
            }
            n(e, t), (e.prototype = null === t ? Object.create(t) : ((o.prototype = t.prototype), new o()));
        }),
    c = function (e, t, o, n) {
        var i,
            a = arguments.length,
            r = a < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, o, n);
        else
            for (var s = e.length - 1; s >= 0; s--)
                (i = e[s]) && (r = (a < 3 ? i(r) : a > 3 ? i(t, o, r) : i(t, o)) || r);
        return a > 3 && r && Object.defineProperty(t, o, r), r;
    };
Object.defineProperty(r, "__esModule", {value: !0});
var l = e("AssetsMap"),
    d = e("BundleNames"),
    u = e("ConfigGameData"),
    p = e("GameData"),
    h = e("GameOverData"),
    f = e("PlayerLevel"),
    _ = cc._decorator,
    y = _.ccclass,
    m = _.property,
    g = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.btn_backHome = null), (t.btn_playAgain = null), (t.btn_lookRanking = null), (t.isOppoView = !1), t
            );
        }
        return (
            s(t, e),
            (t.prototype.addEvent = function () {
                this.btn_backHome.node.on(game.EngineEventType.NodeEvent.click, this.onClick_btn_backHome, this),
                    this.btn_playAgain.node.on(game.EngineEventType.NodeEvent.click, this.onClick_btn_playAgain, this),
                    this.btn_lookRanking.node.on(
                        game.EngineEventType.NodeEvent.click,
                        this.onClick_btn_lookRanking,
                        this
                    );
            }),
            (t.prototype.showBoxAd = function () {
                console.log("------------设置宝箱广告---------"),
                    cc.SDK.showBoxVideo(
                        function (e, t) {
                            if (e == i.COIN) {
                                var o = p.default.instance.getPlayerCoin();
                                p.default.instance.setPlayerCoin(o + t);
                            } else i.DIAMONDS;
                        },
                        function () {
                            cc.SDK.showGetUICoinBox(
                                function (e) {
                                    var t = p.default.instance.getPlayerCoin();
                                    p.default.instance.setPlayerCoin(t + e);
                                },
                                function () {},
                                cc.SDK.gameID
                            );
                        },
                        cc.SDK.gameID
                    );
            }),
            (t.prototype.onEnable = function () {
                cc.SDK.showInterstitial(a.INTERSTITIAL_GAME_OVER), this.showBoxAd();
            }),
            (t.prototype.removeEvent = function () {
                this.btn_backHome.node.off(game.EngineEventType.NodeEvent.click, this.onClick_btn_backHome, this),
                    this.btn_playAgain.node.off(game.EngineEventType.NodeEvent.click, this.onClick_btn_playAgain, this),
                    this.btn_lookRanking.node.off(
                        game.EngineEventType.NodeEvent.click,
                        this.onClick_btn_lookRanking,
                        this
                    );
            }),
            (t.prototype.onClick_btn_backHome = function () {
                ad.adInterface.hideBanner(!0),
                    game.AudioManager.playBtnEffect(),
                    game.UIManager.instance.replaceModuleView(
                        d.default.Start,
                        l.default.StartBundle.prefabs.assetsList.StartModuleView
                    ),
                    this.closeView(!1),
                    ad.curr_platform == window.ad.Platform.OPPO ||
                        (ad.curr_platform == window.ad.Platform.MEI_ZU
                            ? ad.adInterface.showInterstitial()
                            : ad.curr_platform == window.ad.Platform.HUAWEI_GAME &&
                              ad.adInterface.showNativeInterstitial());
            }),
            (t.prototype.onClick_btn_playAgain = function () {
                u.default.instance.ResetData(),
                    ad.adInterface.hideBanner(!0),
                    game.AudioManager.playBtnEffect(),
                    game.PopupManager.instance.showPopView(l.default.PopupMap.MatchPlayersView, null, !1, !1),
                    this.closeView(!1);
                    
                    Adv_skd.default.instance.hideAllAdv();
            }),
            (t.prototype.onClick_btn_lookRanking = function () {
                this.closeView(!1),
                    game.PopupManager.instance.showPopView(l.default.PopupMap.GameOverView3, null, !1, !1);
            }),
            (t.prototype.onLoad = function () {
                this.isCache = !1;
            }),
            (t.prototype.onDisable = function () {
                cc.SDK.hideInterstitial(),
                    ad.curr_platform == window.ad.Platform.OPPO && ad.adInterface.hideNativePatch(!1),
                    ad.curr_platform == window.ad.Platform.BAI_DU && ad.adInterface.hideBanner(!1);
            }),
            (t.prototype.start = function () {
                ad.curr_platform == window.ad.Platform.VIVO &&
                    (ad.adInterface.hideNativeBanner(!1), ad.adInterface.hideBanner(!1)),
                    ad.curr_platform == window.ad.Platform.OPPO
                        ? (ad.adInterface.hideNativeBanner(!1),
                          ad.adInterface.isNativePatchReady() && ad.adInterface.showNativePatch("NativePatch_3"))
                        : ad.curr_platform == window.ad.Platform.QQ
                        ? ad.adInterface.showBanner()
                        : ad.curr_platform == window.ad.Platform.WECHAT
                        ? ad.adInterface.showBanner()
                        : ad.curr_platform == window.ad.Platform.TOU_TIAO
                        ? ad.adInterface.showBanner()
                        : ad.curr_platform == window.ad.Platform.MEI_ZU
                        ? ad.adInterface.showInterstitial()
                        : ad.curr_platform == window.ad.Platform.HUAWEI_GAME
                        ? ad.adInterface.showNativeInterstitial()
                        : ad.curr_platform == window.ad.Platform.BAI_DU && ad.adInterface.showBanner(),
                    ad.curr_platform == window.ad.Platform.TOU_TIAO &&
                        this.param.ttShare &&
                        "" != ad.adInterface.ttGetRecordVideoPath() &&
                        game.PopupManager.instance.showPopView(l.default.PopupMap.TTShareRecorderView, null, !0, !1);
                for (
                    var e = this.node.getChildByName("content"), t = h.default.instance.nowScoreList, o = 0;
                    o < t.length;
                    o++
                )
                    if ((c = t[o]).snake_name == p.default.instance.UserName) {
                        (e.getChildByName("item1").getChildByName("label_score").getComponent(cc.Label).string =
                            c.score + ""),
                            (e.getChildByName("item2").getChildByName("label_score").getComponent(cc.Label).string =
                                c.score + c.oldScore + ""),
                            (e.getChildByName("item3").getChildByName("label_score").getComponent(cc.Label).string =
                                c.killNum + ""),
                            (e.getChildByName("item4").getChildByName("label_score").getComponent(cc.Label).string =
                                c.killScore + "");
                        break;
                    }
                var n = 1,
                    i = h.default.instance.getList1();
                for (
                    e.getChildByName("item1").getChildByName("ranking2").active =
                        i[0].snake_name == p.default.instance.UserName,
                        e.getChildByName("item1").getChildByName("ranking1").active = !e
                            .getChildByName("item1")
                            .getChildByName("ranking2").active,
                        o = 0;
                    o < i.length;
                    o++
                )
                    (c = i[o]).snake_name == p.default.instance.UserName &&
                        (e
                            .getChildByName("item1")
                            .getChildByName("ranking1")
                            .getChildByName("label_ranking")
                            .getComponent(cc.Label).string = o + 1 + "");
                e.getChildByName("item1").getChildByName("ranking2").active && (n += 1);
                var a = h.default.instance.getList2();
                for (
                    e.getChildByName("item2").getChildByName("ranking2").active =
                        a[0].snake_name == p.default.instance.UserName,
                        e.getChildByName("item2").getChildByName("ranking1").active = !e
                            .getChildByName("item2")
                            .getChildByName("ranking2").active,
                        o = 0;
                    o < a.length;
                    o++
                )
                    (c = i[o]).snake_name == p.default.instance.UserName &&
                        (e
                            .getChildByName("item2")
                            .getChildByName("ranking1")
                            .getChildByName("label_ranking")
                            .getComponent(cc.Label).string = o + 1 + "");
                e.getChildByName("item2").getChildByName("ranking2").active && (n += 1);
                var r = h.default.instance.getList3();
                for (
                    e.getChildByName("item3").getChildByName("ranking2").active =
                        r[0].snake_name == p.default.instance.UserName,
                        e.getChildByName("item3").getChildByName("ranking1").active = !e
                            .getChildByName("item3")
                            .getChildByName("ranking2").active,
                        o = 0;
                    o < r.length;
                    o++
                )
                    (c = i[o]).snake_name == p.default.instance.UserName &&
                        (e
                            .getChildByName("item3")
                            .getChildByName("ranking1")
                            .getChildByName("label_ranking")
                            .getComponent(cc.Label).string = o + 1 + "");
                e.getChildByName("item3").getChildByName("ranking2").active && (n += 1);
                var s = h.default.instance.getList4();
                for (
                    e.getChildByName("item4").getChildByName("ranking2").active =
                        s[0].snake_name == p.default.instance.UserName,
                        e.getChildByName("item4").getChildByName("ranking1").active = !e
                            .getChildByName("item4")
                            .getChildByName("ranking2").active,
                        o = 0;
                    o < s.length;
                    o++
                ) {
                    var c;
                    (c = i[o]).snake_name == p.default.instance.UserName &&
                        (e
                            .getChildByName("item4")
                            .getChildByName("ranking1")
                            .getChildByName("label_ranking")
                            .getComponent(cc.Label).string = o + 1 + "");
                }
                e.getChildByName("item4").getChildByName("ranking2").active && (n += 1),
                    (e.getChildByName("bg2").getChildByName("label_reward1").getComponent(cc.Label).string =
                        "积分+" + n),
                    (f.default.instance.score = f.default.instance.score + n);
            }),
            c([m(cc.Button)], t.prototype, "btn_backHome", void 0),
            c([m(cc.Button)], t.prototype, "btn_playAgain", void 0),
            c([m(cc.Button)], t.prototype, "btn_lookRanking", void 0),
            c([m(cc.Boolean)], t.prototype, "isOppoView", void 0),
            c([y], t)
        );
    })(game.BasePopView);
r.default = g;
